// run: $exec < input
#include <iostream>
#include <algorithm>
#include <vector>

int const inf = 1 << 30;
int const maxn = 2100000;
long long a[maxn];
long long n;

int main()
{
	std::ios::sync_with_stdio(false);
	std::cin >> n;
	long long min = inf;
	for (int i = 0; i < n; i++) {
		std::cin >> a[i];
		min = std::min(min, a[i]);
	}

	std::vector<long long> v;
	for (int i = 0; i < n; i++)
		if (a[i] == min) v.push_back(i);

	int tot = v.size();
	long long len = n - 1 - v[tot - 1] + v[0];
	for (int i = 0; i < tot - 1; i++)
		len = std::max(len, v[i + 1] - v[i] - 1);
	std::cout << min*n + len << '\n';
}

